package com.lanyam.travel;


import com.lanyam.travel.TravelApplication;
import com.lanyam.travel.base.utils.JwtUtils;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;


/**
 * @author KingTang
 * @date 	2019/12/30
 */
@Component
public class ServletInitializer extends SpringBootServletInitializer {

	private String jwtSecret = "06a35818325ca87749c7361a0dec9927";

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(TravelApplication.class);
	}

	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {

		//配置JWT的密钥和过期时间
		JwtUtils.init(jwtSecret, 3600000 * 12L);
		super.onStartup(servletContext);
	}
}
